/*
 * @Author: CQJ
 * @Date: 2022-08-25 20:00:27
 * @LastEditors: CQJ
 * @LastEditTime: 2022-09-08 17:22:48
 * @Description:
 */
import { reactive, ref } from 'vue'
import type { ClassifyListData } from '@/types/site/classifyList'
type Key = string
interface ClassifyState {
  // 所属分类
  categ_id?: string | undefined
  // 子分类关键词
  keyword?: string | undefined
  site_id: string | undefined
}

// 状态管理
export const classifyState = reactive<ClassifyState>({
  categ_id: undefined,
  keyword: undefined,
  site_id: undefined
})
interface StatusState {
  isEdit: boolean
  addClassify: boolean
  addSubClassify: boolean
  selectedRowKeys: Key[]
  isAddClass: boolean //是否是添加分类
  isAddSubClass: boolean //是否是添加子类
  classifyList: ClassifyListData[]
  classifyCopyList: ClassifyListData[]
  majorRowData: any
  activeRows: any
}
// 状态管理
export const statusState = reactive<StatusState>({
  isEdit: false,
  addClassify: false,
  addSubClassify: false,
  selectedRowKeys: [],
  isAddClass: false,
  isAddSubClass: false,
  classifyList: [],
  classifyCopyList: [],
  activeRows: [],
  majorRowData: []
})
export interface ICopyList {
  id: string
  name: string
}
export const resetState = () => {
  let key: keyof ClassifyState
  for (key in classifyState) {
    classifyState[key] = undefined
  }
}
